<?php

    function display_header(){
        echo '<html>
        <link rel="stylesheet" href="style.css">
        <link rel="stylesheet" href="include/slider/dhtmlxslider.css">
        <script src="include/slider/js/dhtmlxcommon.js"></script>
        <script src="include/slider/js/dhtmlxslider.js"></script>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <body>

            <div id="global">
                <div id="entete">
                    <h1><center>Virtual Cloud</center></h1>
                    <h2><center>Création de machine virtuelle à la volée</center></h2>
                </div>';
        if(isset($_SESSION['login']) && isset($_SESSION['mdp']))      
            {
          echo '<div id="navigation">
                    <ol>
                        <li><a href="affiche.php">Afficher les clouds</a></li>
                        <li><a href="distributions.php">Créer un cloud</a></li>
                        <li>Tout éffacer</li>
                        <li><a href="update.php">Récupérer les MAJ</a></li>
                    </ol>
                </div>

            <div id="contenu">';
             }
             else {
                 echo '<div id="contenu">';
             }
    }


    
    function is_log() {

        echo '<div id="login">';

        if(isset($_SESSION['login']) && isset($_SESSION['mdp']))
        {
            $name = $_SESSION['login'];
            echo "Bienvenue $name ! <br/>";

            $auth = $_SESSION['Autorisation'];
            if($auth == '3')
            {
                echo "<a href=admin/admin.php>Administration</a><br />";
            }

            echo '<a href="logout.php">Deconnexion</a>';
        }
        else
        {
            echo '<form method="post" action="login.php" >
                <label for="login">Identifiant: </label>
                <input type="text" name="login" size="20" placeholder="Identifiant"/>
                <label for="mdp">Mot de passe: </label>
                <input type="password" name="mdp" placeholder="Mot de passe"/>
                <input type="submit" value="Connexion">
                <a href="FormulaireInscription.php">Inscription</a>
                </form>';
        }

        echo '</div>';
    }

    function display_footer(){
        echo '</div>
            <div id="pied">
              </div>
            </div>
        </body>
    </html>';
    }

    function VM_state ($id, $started) {
        if ($started == 0) { ?>
            
            <a href="start.php?VM=<?php echo $id;?>">
                <img onmouseover="this.src='img/start.png'" onmouseout="this.src='img/poweroff.png'" src="img/poweroff.png" width=40 height=40 alt="Démarrer">
            </a>
        <?php
        }else { ?>
            
            <a href="stop.php?VM=<?php echo $id;?>">
                <img onmouseover="this.src='img/poweroff.png'" onmouseout="this.src='img/start.png'" src="img/start.png" width=40 height=40 alt="Arreter">
            </a>
        <?php
        }
    }
?>